<?php
class UserService extends BaseDbService
{
	public function __construct()
	{
		$this->dao	= new BaseDao('user');
	}
	
	public function add($data)
	{
		$returnSetting = Util::loadSetting('return');
		if(array_key_exists('reg_money', $returnSetting))
		{
			$data['money'] = $returnSetting['reg_money'];
		}
		
		$id = parent::add($data);
		
		return $id;
	}
	
	public function getListByIds($ids)
	{
		if (empty($ids))
		{
			return array();
		}
		$result = $this->rows(array('id'=>array('in'=>$ids)),'',array('id','username','logo','fans_num'));
		$list = array();
		if ($result)
		{
			foreach($result as $item)
			{
				$list[$item['id']] = $item;
				unset($list[$item['id']]['id']);
			}
			unset($result);
		}
		
		return $list;
	}
	
	
	public function getUserByTaobaoNick($nick)
	{
		$con = array('account_type'=>'taobao','account'=>'eq:'.$nick);
		
		$user = $this->fetch($con);
		
		return $user;
	}
}